﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using TESTCommons.JsonHelper;
using TestManage.Infrastructure.CustomAttribute;
using TestModel.SysManage;
using TestService.SysManage;

namespace TestManage.Controllers
{
    [AopActionFilter(true, false)]
    public class SysLogController : Controller
    {
        #region 参数
        private readonly ISys_LogService _logService;
        #endregion

        #region 构造函数
        public SysLogController(ISys_LogService logService)
        {
            _logService = logService;
        }
        #endregion

        [HttpGet]
        public IActionResult Index()
        {
            return View();
        }

        [HttpGet]
        public IActionResult QueryLog(DateTime? fromUtc = null, DateTime? toUtc = null, int pageIndex = 0, int pageSize = int.MaxValue)
        {
            var log = _logService.QueryLog(fromUtc, toUtc, pageIndex, pageSize);
            return Json(log);
        }

        [HttpPost]
        public IActionResult DeleteLog(List<sys_Log> logs)
        {
            _logService.DeleteLog(logs);
            return Json(new AjaxResult { type = ResultType.success, message = "日志删除成功" });
        }
    }
}
